If you are intersted in supporting this format in an editor you can email me for more information at milngavie@globalnet.co.uk. Also I've not completed the specification for type 'Y' scripts. If anyone wants to have a say in the development of type 'Y' please email. Type 'Y' is intended for editors which would replace the complete entry for a monster. Type 'Z' is a hybrid version containing identification blocks which identify the following blocks of data as either type 'X' or type 'Y'. These formats may never materialise if I don't find a good reason to support them. Type 'X' is the only format currently implemented and the only format that MDU requires.
Patches begin with a header as shown below. They then have a series of blocks written one after another with no padding bytes. A termination block is then written at the end of the file. This is just a block with the platform byte set to 2 to break out of MDUs procesing loop. All other bytes in the termination block should be zero. All unused numbers should be set to zero. You can't miss out any of the parts of a block. If they are not used they must be zero.
You might think that type 'X' blocks are not as efficient as they could be. I could have used a single unsigned long instead of having three seperate numbers of different length in a type 'X' block. There is a reason for this - the longest unused block could potentially hold more data - that's why you should set unused parts to zeros. MDU may in the future, encode more data in the parts of blocks which are normally set to zero.
Never write data after the termination block. Although this will work with MDU, it could make the patches impossible to add entries to or cause corruption of the patch when MDU attempts to write more data into it.
//script header - 9 bytes
typedef struct {
unsigned char header; //either 'X', 'Y' or 'Z', depending if it's offset or block replace
unsigned char creator[8]; //program that created patch padded with zeros
} ScriptPatchHeader;
Below: Type 'X' block. NOT given as a structure. unsigned char is an unsigned byte, unsigned short is an unsigned 16 bit word. unsigned long is an unsigned 32 bit word. long is a signed 32 bit word.
unsigned char replaceNumByte; //replacement numbers of various lengths
unsigned short replaceNumShort; //unused numbers should be set at zero
unsigned long replaceNumLong; //numLen shows which number is used
Remember structures MAY NOT have a size which is the sum of the sizes of their component variables. Be careful. Padding bytes are not supported.
Use the sizeof operator to find the size of a structure.
This patch format information is part of the MDU package. You may use this information to write your own patch editors, installers etc. Please make it clear if your program is compatible with the MDU patch format.